fix(loop): pin transient driver units to the repo root via --working-directory - #131
Merged
Merged
Conversation
…directory A systemd-run --user transient unit defaults WorkingDirectory to $HOME, so every driver spawned via issue #119's transient-unit path started outside the repo, never loaded .claude/settings.local.json's bypassPermissions profile, and died phantom on its first gh call ("requires approval", no approver headless). Went live at the 2026-07-16 08:38Z re-arm and burned all 5 of issue #97's attempts in ~1h before the #95 attempt budget parked the loop. Scenario 11 now asserts the flag is passed with the resolved repo root. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
robercano
approved these changes
Jul 16, 2026
This was referenced Jul 16, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since the 2026-07-16 08:38Z re-arm (which activated #119's transient-unit spawn path), every loop driver started in
$HOMEinstead of the repo:systemd-run --usertransient units default their WorkingDirectory to the user's home. A driver started there never loadsreCode/.claude/settings.local.json'sbypassPermissionsprofile, so its firstgh/bot-gh.shcall dies on "requires approval" (no approver in headless-pmode) and the driver exits clean with no work — ledgeredresult=phantom rc=0by #111's classifier.Impact: issue #97 burned all 5 of its
per_issue_attemptson back-to-back phantoms in ~1h before the #95 attempt budget parked the loop withneeds-humanescalation.Forensic fingerprint for future debugging: a homeless driver's transcript files under
~/.claude/projects/-home-rcano/instead of...-reCode/.Fix
One flag on the
systemd-runinvocation inrun_driver:--working-directory="$root". The setsid fallback path needs no change — a plain child inherits the daemon's own cwd (the repo, per the service unit).Tests
Scenario 11 now asserts
--working-directory=<resolved repo root>is passed. Fullloop-daemon.test.sh: 75/75 green; self test + lint gates green.Deploy note
Takes effect only on daemon restart (functions load at start). The loop is currently parked on
reason=attempt-budget, so restarting is safe right now. After restart, clear issue #97's entry in.claude/state/loop-issue-attempts.jsonto let it retry.🤖 Generated with Claude Code